//
//  TicketDetailModel.swift
//  ANOA
//
//  Created by WB Zhou on 2017/4/7
//  Copyright (c) aonong. All rights reserved.
//

import Foundation

public struct TicketDetailModel: SwiftyJSONAble {
    
    // MARK: Declaration for string constants to be used to decode and also serialize.
    private struct SerializationKeys {
        static let idKey = "id_key"
        static let fVouid = "f_vouid"
        static let fGoodsname = "f_goodsname"
        static let fUnitprice = "f_unitprice"
        static let fDetailamount = "f_detailamount"

    }
    
    // MARK: Properties
    public var idKey: Int?
    public var fVouid: Int?
    public var fGoodsname: String?
    public var fDetailamount: String?
    public var fUnitprice: Float?
 
    // MARK: SwiftyJSON Initializers
    /// Initiates the instance based on the object.
    ///
    /// - parameter object: The object of either Dictionary or Array kind that was passed.
    /// - returns: An initialized instance of the class.
    public init(object: Any) {
        self.init(json: JSON(object))
    }
    
    /// Initiates the instance based on the JSON that was passed.
    ///
    /// - parameter json: JSON object from SwiftyJSON.
    public init(json: JSON) {
        idKey = json[SerializationKeys.idKey].int
        fVouid = json[SerializationKeys.fVouid].int
        fGoodsname = json[SerializationKeys.fGoodsname].string
        fDetailamount = json[SerializationKeys.fDetailamount].string
        fUnitprice = json[SerializationKeys.fUnitprice].float
    }
    
    /// Generates description of the object in the form of a NSDictionary.
    ///
    /// - returns: A Key value pair containing all valid values in the object.
    public func dictionaryRepresentation() -> [String: Any] {
        var dictionary: [String: Any] = [:]
        if let value = idKey { dictionary[SerializationKeys.idKey] = value }
        if let value = fVouid { dictionary[SerializationKeys.fVouid] = value }
        if let value = fGoodsname { dictionary[SerializationKeys.fGoodsname] = value }
        if let value = fDetailamount { dictionary[SerializationKeys.fDetailamount] = value }
        if let value = fUnitprice { dictionary[SerializationKeys.fUnitprice] = value }
 
        return dictionary
    }
    
}
